﻿<UserControl x:Class="ScrumTable.UI.View.WinTouch.UserControls.HtmlRichText.Controls.RichTextEditor" x:Name="uxRichTextEditor"    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:asis="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.HtmlRichText.AttachedProperties" xmlns:Controls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.HtmlRichText.Controls" xmlns:Controls1="clr-namespace:Microsoft.Surface.Presentation.Controls;assembly=Microsoft.Surface.Presentation" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" >
  
    <Grid>

        <!-- Set the styles for the tool bar. -->
        <Grid.Resources>
            <Style TargetType="{x:Type Controls1:SurfaceButton}" x:Key="formatTextStyle" BasedOn="{StaticResource SurfaceButtonStyle}">
                <Setter Property="FontFamily" Value="Palatino Linotype"></Setter>                
                <Setter Property="FontSize" Value ="14"></Setter>                
                <Setter Property="Padding" Value ="0"></Setter>
                <Setter Property="Background" Value ="White"></Setter>                
                <Setter Property="Margin" Value ="0"></Setter>
                <Setter Property="Height" Value ="30"></Setter>
                <Setter Property="Width" Value ="45"></Setter>
                <!--
                <Setter Property="ToolBar.OverflowMode" Value="Never"/>               
                -->
                
                <Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>
            </Style>
 
            <Style TargetType="{x:Type Controls1:SurfaceButton}" x:Key="formatImageStyle" BasedOn="{StaticResource SurfaceButtonStyle}">                
                <Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"></Setter>
                <Setter Property="Background" Value ="White"></Setter>
                <Setter Property="Margin" Value ="0"></Setter>
                <Setter Property="Padding" Value ="0"></Setter>
                <Setter Property="Height" Value ="30"></Setter>
                <Setter Property="Width" Value ="45"></Setter>
                <!--
                <Setter Property="ToolBar.OverflowMode" Value="Never"/>
                -->
            </Style>

            <Style TargetType="{x:Type Rectangle}">                
                <Setter Property="Width" Value="20"></Setter>
                <Setter Property="Height" Value="20"></Setter>                                
            </Style>
        </Grid.Resources>

        <Grid Name="mainPanel">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" MaxHeight="35"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <!-- This tool bar contains all the editing buttons. -->
            <ToolBar ToolBarTray.IsLocked="True"  VerticalAlignment="Top" IsTabStop="False" KeyboardNavigation.IsTabStop="False" KeyboardNavigation.TabNavigation="Continue">                

                <Controls1:SurfaceButton  Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Cut">
                    <Rectangle Fill="{StaticResource Iconeditcut}"/>
                </Controls1:SurfaceButton>                
                <Controls1:SurfaceButton  Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Copy">                    
                    <Rectangle Fill="{StaticResource Iconeditcopy}"/>
                    </Controls1:SurfaceButton >
                <Controls1:SurfaceButton  Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Paste">                    
                    <Rectangle Fill="{StaticResource Iconeditpaste}"/>
                    </Controls1:SurfaceButton >                
                <Controls1:SurfaceButton  Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Undo">                    
                    <Rectangle Fill="{StaticResource Iconeditundo}"/>
                    </Controls1:SurfaceButton >
                <Controls1:SurfaceButton  Style="{StaticResource formatImageStyle}" Command="ApplicationCommands.Redo">                    
                    <Rectangle Fill="{StaticResource Iconeditredo}"/>
                    </Controls1:SurfaceButton >
                <Controls1:SurfaceButton  Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleBold">
                    <TextBlock FontWeight="Bold">B</TextBlock>
                    </Controls1:SurfaceButton >
                <Controls1:SurfaceButton  Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleItalic">
                    <TextBlock FontStyle="Italic" FontWeight="Bold">I</TextBlock>
                    </Controls1:SurfaceButton >
                <Controls1:SurfaceButton  Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleUnderline">
                    <TextBlock TextDecorations="Underline" FontWeight="Bold">U</TextBlock>
                </Controls1:SurfaceButton >            
         <!--
                <Controls1:SurfaceButton Style="{StaticResource formatImageStyle}" Command="EditingCommands.IncreaseFontSize">                    
                    <Rectangle Fill="{StaticResource Iconcharactergrowfont}"/>
                </Controls1:SurfaceButton>
                <Controls1:SurfaceButton Style="{StaticResource formatImageStyle}" Command="EditingCommands.DecreaseFontSize">                    
                    <Rectangle Fill="{StaticResource Iconcharactershrinkfont}"/>
                </Controls1:SurfaceButton>
          -->
                <Controls1:SurfaceButton Style="{StaticResource formatImageStyle}" Command="EditingCommands.ToggleBullets">
                    <Rectangle Fill="{StaticResource Iconlistbullets}"/>
                </Controls1:SurfaceButton>
                <Controls1:SurfaceButton Style="{StaticResource formatImageStyle}" Command="EditingCommands.ToggleNumbering">
                    <Rectangle Fill="{StaticResource Iconlistnumbering}"/>
                </Controls1:SurfaceButton>
                <!--
                <Controls1:SurfaceButton Style="{StaticResource formatImageStyle}" Command="EditingCommands.IncreaseIndentation">
                    <Rectangle Fill="{StaticResource Iconparagraphincreaseindentation}"/>
                </Controls1:SurfaceButton>
                <Controls1:SurfaceButton Style="{StaticResource formatImageStyle}" Command="EditingCommands.DecreaseIndentation">
                    <Rectangle Fill="{StaticResource Iconparagraphdecreaseindentation}"/>
                </Controls1:SurfaceButton>
                -->
            </ToolBar>
            <RichTextBox  Grid.Row="1" Name="mainRTB" AcceptsTab="True" asis:RichTextboxAssistant.BoundDocument="{Binding Path=Text, ElementName=uxRichTextEditor, ValidatesOnExceptions=True}"  VerticalScrollBarVisibility="Auto" Background="White">               
                <FlowDocument PageWidth="{Binding ElementName=mainRTB, Path=ActualWidth}"  />
            </RichTextBox>          

        </Grid>
    </Grid>
</UserControl>
